import time

from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "dbshopST013_分类编辑"

# 打开后台网址
firefox = openBrowser(urlAdmin)
# 登陆
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,'商品管理', '管理分类','商品分类')
firefox.find_element_by_partial_link_text('添加分类').click()
firefox.find_element_by_id('class_name').send_keys('商品分类测试')
firefox.find_element_by_id('class_sort').clear()
firefox.find_element_by_id('class_sort').send_keys('1')
firefox.find_element_by_xpath('//button[contains(text(),"保存分类")]').click()
firefox.find_element_by_xpath("//td[contains(.,'商品分类测试')]/following-sibling::td[4]/a[2]").click()
firefox.find_element_by_id('class_sort').clear()
firefox.find_element_by_id('class_sort').send_keys("4")
firefox.find_element_by_xpath('(//button)[2]').click()
time.sleep(3)
#断言：
try:
    firefox.find_element_by_xpath("//td[contains(.,'商品分类测试')]")
    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()

